package com.hh.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.time.ZonedDateTime;

@Configuration
public class RouterConfig {

    /**
     * 代码的路由 yml也可以使用 不会冲突的 都可以用
     * 如果uri后面给了访问地址和匹配地址相同 那就不会拼接
     * @param builder
     * @return
     */
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                .route("guochuang-id", r -> r.path("/guochuang").uri("https://www.bilibili.com/"))
                .route("dance-id", r -> r.path("/v/dance").uri("https://www.bilibili.com/"))
                .route("kichiku-id", r -> r.path("/v/kichiku").uri("https://www.bilibili.com/"))
                .build();
    }
}
